//设备报修
/**
 * @name Dutt
 */
import Axios from "./../utils/axios";
import api from "./../api/index"
/**
 * 设备报修的分页和条件查询
 * @param {*} page 第几页
 * @param {*} limit 多少条
 * @param {*} facilityName 名称
 * @param {*} facilityEncoding 编码
 * @param {*} repairsTime 报修开始时间
 * @param {*} maintainTime 修理开始时间
 * @param {*} id 选择的数据id
 * @returns 
 */
function repairsPage(list) {
    return Axios.post(api.apiRepairs.repairsPage, list)
}
function repairsAdd(List) {
    console.log("in", List);
    return Axios.post(api.apiRepairs.repairsAdd, List)
}
/**
 * 
 * @param {*} facilityEncoding 条件查询时的编码
 * @param {*} facilityName 条件查询时的名称
 * @param {*} id 
 * @param {*} limit 多少条
 * @param {*} page 当前页
 * @param {*} scrapTime 条件查询时的报废时间
 * @returns 
 */
function scrapPage(facilityEncoding, facilityName, id, limit, page, scrapTime) {
    return Axios.post(api.apiRepairs.scrapPage,
        { facilityEncoding, facilityName, id, limit, page, scrapTime })
}
/**
 * 
 * @returns 返回设备的分类
 */
function facilityClass() {
    return Axios.get(api.apiRepairs.facilityClass)
}
/**
 * 返回存放地点
 */
function storageSite() {
    return Axios.get(api.apiRepairs.storageSite)
}
/**
 * 报废的批量删除
 * @param {Array} id 批量删除id 
 * @returns 
 */
function scrapBathDelete(ids) {
    return Axios.post(api.apiRepairs.scrapBathDelete+"?ids="+ids)
}
/**
 * 
 * @param {int} id 取消的id
 */
function scrapDelete(id) {
    return Axios.get(api.apiRepairs.scrapDelete + id)
}
/**
 * 报废修改信息
 * @returns 
 */
function scrapUpdate(list) {
    return Axios.post(api.apiRepairs.scrapUpdate,list)
}
/**
 *  设备保修的批量删除
 * @param {Array} ids 批量删除的id数组
 * @returns 
 */
function repairsBathDelete(ids) {
    console.log(ids);
    return Axios.post(api.apiRepairs.repairsBathDelete + "/" + ids)
}
/**
 * 新增报废
 * @returns 
 */
function scrapAdd(list) {
    return Axios.post(api.apiRepairs.scrapAdd,list)
}
/**
 * 完成维修
 * @param {*} id 完成报修的id
 * @returns 
 */
function repairsUpdate(id, maintainExpend) {
    return Axios.post(api.apiRepairs.repairsUpdate, {
        id, maintainExpend
    })
}
/**
 * 取消报修
 * @param {int} id 需要取消报修的id 
 */
function repairsDelete(id) {
    return Axios.get(api.apiRepairs.repairsDelete + "/" + id)
}
/**
 * 
 * @param {*} page 当前页
 * @param {*} limit 每页显示条数
 * @param {*} returnState 状态随机传
 * @param {*} returnTime 时间
 * @param {*} facilityName 设备名查询
 * @returns 
 */
function leasePage(page, limit, returnState, returnTime, facilityName) {
    return Axios.post(api.apiRepairs.leasePage, {
        page, limit, returnState, returnTime, facilityName
    })
}
/**
 * 设备保修中的修改
 * @param {*} list 
 * @returns 
 */
function updateRepairs(list) {
    return Axios.post(api.systemSettings.updateRepairs,list)
}
export default {
    repairsPage,
    scrapPage,
    facilityClass,
    storageSite,
    scrapBathDelete,
    scrapDelete,
    scrapUpdate,
    repairsBathDelete,
    scrapAdd,
    repairsUpdate,
    leasePage,
    repairsAdd,
    repairsDelete,
    updateRepairs
}